﻿
@{
    ViewBag.Title = "HospitalRegin";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
    
}

<script>
        $(function () {
            var url = location.search; //获取url中"?"符后的字串
            var surl = url.substring(url.indexOf("str"));
            var id = url.substring(4);
            $("#But").on("click", function () {
                var name = $.trim($("#name").val());
                var pwd = $.trim($("#pwd").val());
                if (name == "")
                { 
                   alert("输入的账号有误");
                   return 0;
                }
                if (pwd == "")
                {
                    alert("输入的密码有误"); 
                    return 0;
                }
              $.ajax({
                 type:"post",
                 url: "/Hospital/Adduser",
                 data: {
                   name:name,
                   pwd:pwd,
                   Id:$("#Id").val()
                 },
                 error: function () {
                 alert('a');
                 },
                 success: function (d) {
                     if (d > 0) {
                         alert("注册成功");
                         //location.href = "/Admin/Hospital";   
                           
                           location.href="/Hospital/Login";
                     }
                     else {
                         alert("注册失败");
                     }
                 }
              })
            })
        })
</script>

<body>
    <div>
        <form>

            <table class="table">
                <tr>
                    <td>用户名</td>
                    <td><input type="text" id="name" /></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="password" id="pwd" /></td>
                </tr>
                <tr>
                    <td>选择医院</td>
                    <td>@Html.DropDownList("Id")</td>
                </tr>
                <tr>
                    <td></td>
                    <td><input class="btn btn-sm" type="button" value="注册" id="But" /></td>
                </tr>
            </table>
        </form>

    </div>
</body>





